<?php
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
header('Content-Type: charset=utf-8');
include '../operations/connection.php';

	 	$idtestproject = $_REQUEST['idtestproject'];
		$id_employee = $_REQUEST['id_employee'];
		$id = $_REQUEST['idproject'];
		$indexcomment = $_REQUEST['indexcomment'];
		$recyclebin = $_REQUEST['recyclebin'];
		$newlang = $_REQUEST['newlang'];
		$page = isset ( $_REQUEST["page"] ) ? intval ( $_REQUEST["page"] ) : 1;
		if ($_REQUEST['newlang'] == "EN") {
			include "../value/value_en.php";
		} else if($_REQUEST['newlang'] == "VN") {
			include "../value/value_vn.php";
		}
		else {
			include "../value/value_kr.php";
		}
		
		$queryListErrorByIDPr = mysql_query("SELECT tp.IDTest, tp.IDProject, tp.IDEmployee, tp.Title, tp.TextTest, tp.Time, tp.`Status`,e.FullName,tp.`Delete`
			   FROM pr_testproject tp, employee e WHERE tp.IDTest = '$idtestproject' AND tp.IDProject = '$id' AND e.IDEmployee = tp.IDEmployee 
			   AND tp.`Delete` = $recyclebin ORDER BY IDTest DESC;");
$listattach = mysql_query('select id, testprojectid, filepath, filereal, filename, filetype, filesize, createdate
		 from pre_attach where testprojectid='.$idtestproject);
		
?>
<?php while ($row=mysql_fetch_array($queryListErrorByIDPr)){
				$idemplTestpro = $row[IDEmployee];
				$prdelete = $row[Delete];
				$titletestpro = $row[Title];
				$contenttestpro = $row[TextTest];
				$fullnames = $row[FullName];
				$time = $row[Time];
				
				
				$stringcolortest = substr($row[Title],0,-14);
				$color = substr($row[Title],-6); ?>
			<td class="rf-dt-c"
						style="width: 25px; vertical-align: middle; text-align: center;min-width: 25px"><?php echo $indexcomment?>
					</td>
					<td class="rf-dt-c" colspan="4"
						style="padding: 0; vertical-align: middle;">
						
						<div  style="background:white; border:1px solid #c4c0c9; padding:10px;margin:9px;" id="parentcommand">
						
							<div class="acomment" id="themcommand" style="background:white; border:1px solid #c4c0c9; padding:10px;display: none">
		                    	<ul class="buttonColor">
		                    		<li style="vertical-align: middle;font-weight: normal;">
		                    			<input id="buttonB023AB" type="button" class="button1" name="buttonB023AB" onclick="addStyle1ColorCommand(this)"/> <font color="#000000"><?php echo $l_no_fix?></font>
									</li>
									<li style="vertical-align: middle;font-weight: normal;">
										<input type="button" class="button2" name="buttonB02323" onclick="addStyle2ColorCommand(this)"/> <?php echo $l_error?>
									</li>
									<li style="vertical-align: middle;font-weight: normal;">
										<input type="button" class="button3" name="button3DA850" onclick="addStyle3ColorCommand(this)"/> <?php echo $l_fix_complete?>
									</li>
		                    	</ul>
		                        <br class="clear" />
		                    	<span style="display: block; text-align: left"><?php echo $l_comment?> : </span>
		                    	<textarea style="width:100%; border:1px solid #c4c0c9" cols="5" rows="3" id="titlecomment" name="titlecomment"></textarea>
		                        <div style="text-align:right">
		                            <input class="buttonProject" type="button" style="margin: 5px 0;" value="OK" onclick="add_comment('<?=$idtestproject?>','<?=$id_employee?>',this);"/>
		                            <input class="buttonProject aclose" type="button" style="margin: 5px 0;" value="Cancel" id="cancelthemcommand" onclick="closethemcommand(this)"/>
		                        </div>
	                   		</div> 
							
							<div class="odd1" style=" padding-left:10px; border:1px solid #ddd; font-size: 13px;" id="ajaxLstComment">
								<div  style="background:#f7f7f7; padding:10px;  font-weight:bold; color:#b02323">
								
								<?php 
									if(strlen($stringcolortest)==0){?>
										<font style="color:#6290ff"><?php echo  $titletestpro ?> </font>
									<?php 
									} 
								switch ($color){
									case 'B023AB':
										?> <font style="color:#B023AB"><?php echo  $stringcolortest ?> </font> <?php	break;
									case '424242':
										?> <font style="color:#424242"><?php echo  $stringcolortest ?> </font> <?php	break;
									case '3DA850':
										?><font style="color:#3da850"><?php echo  $stringcolortest ?> </font> <?php	break;
									case 'B02323':
										?><font style="color:#B02323"><?php echo  $stringcolortest ?> </font> <?php	break;
									default:
										?> <font style="color:#424242"><?php echo  $stringcolortest ?> </font> <?php	break;
								}?>
								</div>
								<div style="background:#ffffff;  padding:10px; "><?php echo $contenttestpro?></div>
								<div style="padding:0 8px">
								
								<?php 
								$temindex = 0;
								while ($rowattach = mysql_fetch_array($listattach)) {?>
									<div style="padding:1px">
										<img src="images/dinhkem.png"/>
										<a
											href="admin/attach/downloadattach.php?filepath=<?=$rowattach[filereal]?>&filename=<?=$rowattach[filename]?>&filetype=<?=$rowattach[filetype]?>">
											<?=$rowattach[filename]."(".$rowattach[filetype].") ".$rowattach[filesize]?></a>
									</div>
								<?php $temindex+=1;}
								?>
								</div>
								<div style="border-bottom: 1px dotted gray; padding-bottom: 5px;margin-bottom: 5px;"></div>
							</div>
							
	                        <div style="background:#f7f7f7; width:100%"> 
	                            <div style=" padding:10px; font-size:11px; color:#000; float:left; width:60%"><?php echo $fullnames."(".$time.")"?></div>
	                            <div style="float:right;">
	                            <?php if(($idemplTestpro==$id_employee) || ($_SESSION['posmanager']==1)){
								
							?>
	                                <input class="buttonProject " type="button" style="margin: 5px 0;width: 70px" value="<?=$l_delete?>" 
	                                onclick="if(confirm('<?php echo $l_confirm_deleteproject?>')){ delete_test_project_recyclebin('<?=$prdelete?>','<?=$idtestproject?>','<?=$id?>','<?=$id_employee?>','<?=$page?>',this); return true;}else{return false;}"/>
	                                <input class="buttonProject hclose" type="button" style="margin: 5px 0;width: 70px" value="<?=$l_close?>" onclick="onclickRecycleBin('<?=$id?>','<?=$id_employee?>','<?=$page?>')"/>
	                           
	                            <?php }else{
	                            	?>
	                            	<input class="buttonProject hclose" type="button" style="margin: 5px 0;width: 70px" value="<?=$l_close?>" onclick="onclickRecycleBin('<?=$id?>','<?=$id_employee?>','<?=$page?>')"/>
	                            	<?php 
	                            }?>
	                             </div>
	                            <div class="clear"></div> 
	                        </div>
	                        
	                       
							<?php $querycomment = mysql_query("select c.IDComment,c.IDTestProject,c.IDEmployee,c.Comment,c.DateComment,
								 e.IDEmployee,e.FullName,c.IDTestProject from pr_comment c, employee e 
									 where c.IDEmployee = e.IDEmployee and c.IDTestProject = '$idtestproject' ORDER BY  c.DateComment ASC;")?>
	                       
	                       
	                        <div style="background:white; padding:5px; border:1px solid #ddd; font-size: 13px;"> 
	                        	<div style="background:white; padding:5px; border:1px solid #ddd;" id="ajaxcomment"> 
	                        <?php 
	                        if(count($querycomment)>0){
	                        	?>
	                  <table style="width: 100%;">
	                        <?php  
		                        $vitri=0;
		                        while ($rowcoment = mysql_fetch_array($querycomment)){
		                        	$vitri++;
		                        		$idcomment = $rowcoment[IDComment];
		                        		$idemployeecomment = $rowcoment[IDEmployee];
										$stringcolor = substr($rowcoment[Comment],0,-14);
										$colorcomment = substr($rowcoment[Comment],-6);?>
									
							<tr id="mo" style="background: <?php if($vitri%2==0) 
															echo '#f2f9ff'; 
													else echo '#ffffff';?>; font-size: 13px;">
								<td class="rf-dt-c" style="padding: 0; vertical-align: middle; width: auto;">
	                        
		                        	<span style="color:#b023ab; font-size: 13px;"><?php 
										switch ($colorcomment){
											case 'B023AB':
												?> <font style="color:#B023AB"><?php echo  " + ".$stringcolor ?> </font>
												<?php	break;
											case '424242':
												?> <font style="color:#424242"><?php echo  " + ".$stringcolor ?> </font> <?php	break;
											case '3DA850':
												?><font style="color:#3da850"><?php echo  " + ".$stringcolor ?> </font> <?php	break;
											case 'B02323':
												?><font style="color:#B02323"><?php echo  " + ".$stringcolor ?> </font> <?php	break;
											default:
												?> <font style="color:#424242"><?php echo  " + ".$stringcolor ?> </font> <?php break;
										}?>
									</span>
	                            	<i style="color:#424242; display:block; text-align:right; padding-top:5px;padding-right:15px; font-size: 13px;"><?php echo $rowcoment[FullName]." (".$rowcoment[DateComment].")"?></i>
	                           </td>
	                           <td class="rf-dt-c" style="width: 25px; vertical-align: middle; text-align: center;min-width: 80px">
		                          <?php 
									if(($idemployeecomment==$id_employee)|| ($_SESSION['posmanager']==1)){?>
		                           <a href="#" onclick="if(confirm('<?php echo $l_confirm_deleteproject?>')){ delete_comment('<?=$idcomment?>','<?=$idtestproject?>','<?=$id_employee?>',this);return true}else{return false}">[ <?=$l_delete?> ]</a>
		                         <?php }else {}?>
							   </td>
						</tr>
	                   <?php }?>
	               </table>
	               <?php }?>
	                       
	                     </div>
	                        </div>
	                        
						</div>
						
						</td>
						<?php }?>
						<?mysql_close($connection);?>